﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

public partial class CarBooking
{
    private string connectionstr = "";
    public string connectionString
    {
        get { return connectionstr; }
        set { connectionstr = value; }
    }

    /// <summary>
    /// return error message
    /// </summary>
    private string error = null;
    public string ErrorMessage
    {
        get { return error; }
    }

    /// <summary>
    /// Constructor.
    /// </summary>
    public CarBooking()
    {
        //
        // TODO: Add constructor logic here
        //
        //connectionstr = connectionstr; //WebConfigurationManager.ConnectionStrings["DBNhanSu"].ConnectionString;
    }

    /// <summary>
    /// overload constructor - with connectionstring
    /// Set the connectionString
    /// </summary>
    public CarBooking(string connectionstring)
    {
        connectionstr = connectionstring;
    }

    public DataTable ListRequest(string commandtext, string[]param, string[] value)
    {
        DataTable tbl = new DataTable();
        DataProvider dp = new DataProvider(connectionstr);
        dp.CommandText = commandtext;
        dp.CommandType = CommandType.StoredProcedure;
        dp.ParameterCollection = param;
        dp.ValueCollection = value;
        tbl = dp.GetDataTable();
        dp.CloseConnection();
        return tbl;
    }

    public bool CreateUpdateBookingRequest(string commandtext, string[] param, string[] value)
    {
        DataTable tbl = new DataTable();
        DataProvider dp = new DataProvider(connectionstr);
        dp.CommandText = commandtext;
        dp.CommandType = CommandType.StoredProcedure;
        dp.ParameterCollection = param;
        dp.ValueCollection = value;
        bool r = (dp.ExecuteNonQuery() > 0);
        dp.CloseConnection();
        return r;
    }

}
